package cn.sc.summer.calculate.score;

import cn.sc.summer.calculate.math.MathUtil;
import cn.sc.summer.system.po.SystemInfoDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

/**
 * 类名：PhysicalMemory计算分值
 *
 * @author a-xin
 * @date 2024/3/20 15:12
 */
@Slf4j
@Service
public class PhysicalMemoryScore extends Score {

    /**
     * 分数计算
     *
     * @param info 计算信息
     */
    @Override
    public <T extends SystemInfoDTO> BigDecimal computeScore(T info) {
        Map<String, BigDecimal> dataMap = new HashMap<>();
        Map<String, BigDecimal> weigtMap = new HashMap<>();
        dataMap.put("physicalMemoryTotal", new BigDecimal(info.getPhysicalMemoryTotal()));
        weigtMap.put("physicalMemoryTotal", new BigDecimal("0.6"));
        dataMap.put("physicalMemoryFree", new BigDecimal(info.getPhysicalMemoryFree()));
        weigtMap.put("physicalMemoryFree", new BigDecimal("0.4"));
        return MathUtil.weightedSum(dataMap, weigtMap);
    }
}
